package com.xuelang.pipeline.artifact.client.resource;

import com.xuelang.pipeline.artifact.client.common.constant.DictDTO;
import com.xuelang.pipeline.artifact.client.common.request.PageParam;
import com.xuelang.pipeline.artifact.client.common.result.ApiResult;
import com.xuelang.pipeline.artifact.client.common.result.PageRecord;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactAttributeDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactToolDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactToolQuery;
import com.xuelang.pipeline.artifact.client.resource.dto.PipelineArtifactToolDTO;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 制品工具服务API
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
public interface IArtifactToolService {

    /**
     * 查询制品工具列表-提供流水线使用
     *
     * @return
     */
    @PostMapping(value = "/listArtifactTool", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<PipelineArtifactToolDTO>> listArtifactTool();

    /**
     * 查询制品工具列表(有过滤条件，可以分页)
     *
     * @param dtoPageParam 查询条件
     * @return
     */
    @PostMapping(value = "/pageList", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<ArtifactToolDTO>> pageArtifactToolList(@RequestBody @Valid PageParam<ArtifactToolQuery> dtoPageParam);

    /**
     * 查询制品工具列表(有过滤条件)
     *
     * @param artifactToolQuery 查询条件
     * @return
     */
    @PostMapping(value = "/list", produces = "application/json;charset=utf-8")
    ApiResult<List<ArtifactToolDTO>> conditionalArtifactToolList(@RequestBody @Valid ArtifactToolQuery artifactToolQuery);

    /**
     * 新增制品工具
     *
     * @param artifactToolDTO 制品工具DTO
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> addArtifactTool(@RequestBody @Valid ArtifactToolDTO artifactToolDTO);

    /**
     * 更新制品工具
     *
     * @param artifactToolDTO 制品工具DTO
     * @return
     */
    @PutMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> updateArtifactTool(@RequestBody @Valid ArtifactToolDTO artifactToolDTO);

    /**
     * 删除制品工具
     *
     * @param artifactToolUuid 制品工具UUID
     * @return
     */
    @DeleteMapping(value = "/{artifactToolUuid}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> deleteArtifactTool(@PathVariable("artifactToolUuid") String artifactToolUuid);
    /**
     * 查询制品工具
     *
     * @param artifactToolUuid 制品工具UUID
     * @return
     */
    @GetMapping(value = "/get/{artifactToolUuid}", produces = "application/json;charset=utf-8")
    ApiResult<ArtifactToolDTO> queryArtifactTool(@PathVariable("artifactToolUuid") String artifactToolUuid);

    /**
     * 获取制品仓库地址前缀
     *
     * @param artifactType 制品类型 取值范围为:GENERIC/DOCKER/MAVEN/NPM
     * @return
     */
    @GetMapping(value = "/url/{artifactType}", produces = "application/json;charset=utf-8")
    ApiResult<String> getArtifactUrlPrefix(@PathVariable("artifactType") String artifactType);

    /**
     * 得到仓库指南
     *
     * @param artifactToolUuid 制品仓库UUID
     * @param userId           用户ID
     * @return
     */
    @GetMapping(value = {"/guide/{artifactToolUuid}/{userId}", "/guide/{artifactToolUuid}"}, produces = "application/json;charset=utf-8")
    ApiResult<ArtifactAttributeDTO> getArtifactGuide(@PathVariable("artifactToolUuid") String artifactToolUuid, @PathVariable(value = "userId", required = false) String userId);


    /**
     * 获取构建的镜像仓库列表字典
     *
     * @return
     */
    @PostMapping(value = "/build/imageRepo/dict", produces = "application/json;charset=utf-8")
    ApiResult<List<DictDTO>> queryImageRepoDict();

    /**
     * 获取构建的maven仓库列表字典
     */
    @PostMapping(value = "/build/mavenRepo/dict", produces = "application/json;charset=utf-8")
    ApiResult<List<DictDTO>> queryMavenRepoDict();
}
